/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package CSISL4pk;

import java.sql.*;
/**
 *
 * @author Josh
 */
public class LogoutSubmitSQL {
    //private ResultSet rs;
    private Boolean loggedIn = true;
    public LogoutSubmitSQL(){
        
    }
    public Boolean isLoggedIn(){
        return loggedIn;
    }
    public void logoutNow(int userID,String startTime, String endTime, Boolean canEdit){
        try{ 
        
            String myDriver = "com.mysql.jdbc.Driver";
            String myUrl = "jdbc:mysql://www.db4free.net:3306/csisl";//www.freesql.org:3306/csisl";//"jdbc:mysql://SQL09.FREEMYSQL.NET:3306/csisl";

            Class.forName(myDriver);
            //Connection conn = DriverManager.getConnection(myUrl, "pablofig","cs2450");
            Connection conn = DriverManager.getConnection(myUrl, "csisaltlake","cs2450");
            // our SQL SELECT query. 
            // if you only need a few columns, specify them by name instead of using "*"
            String upSt = "INSERT INTO session(userId,startTime, endTime, canEdit) VALUES("+userID+",'"+startTime+"','"+endTime+"','"+canEdit+"')";
            System.out.print(upSt);
            // create the java statement
            Statement st = conn.createStatement();

            // execute the query
            st.execute(upSt);
            //on finish always close connection
            st.close();
            loggedIn =  false;//investigator now signed out
        }
        catch(Exception e){
             System.out.print(e);
             loggedIn = true;//investigator still signed in
        }
    
    }
}
